package com.ruoyi.blog.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.blog.domain.SitePush;
import com.ruoyi.blog.service.ISitePushService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 百度推送Controller
 * 
 * @author ruoyi
 * @date 2024-08-05
 */
@RestController
@RequestMapping("/blog/sitePush")
public class SitePushController extends BaseController
{
    @Autowired
    private ISitePushService sitePushService;

    /**
     * 查询百度推送列表
     */
    @PreAuthorize("@ss.hasPermi('blog:sitePush:list')")
    @GetMapping("/list")
    public TableDataInfo list(SitePush sitePush)
    {
        startPage();
        List<SitePush> list = sitePushService.selectSitePushList(sitePush);
        return getDataTable(list);
    }

    /**
     * 导出百度推送列表
     */
    @PreAuthorize("@ss.hasPermi('blog:sitePush:export')")
    @Log(title = "百度推送", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SitePush sitePush)
    {
        List<SitePush> list = sitePushService.selectSitePushList(sitePush);
        ExcelUtil<SitePush> util = new ExcelUtil<SitePush>(SitePush.class);
        util.exportExcel(response, list, "百度推送数据");
    }

    /**
     * 获取百度推送详细信息
     */
    @PreAuthorize("@ss.hasPermi('blog:sitePush:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sitePushService.selectSitePushById(id));
    }

    /**
     * 新增百度推送
     */
    @PreAuthorize("@ss.hasPermi('blog:sitePush:add')")
    @Log(title = "百度推送", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SitePush sitePush)
    {
        return toAjax(sitePushService.insertSitePush(sitePush));
    }

    /**
     * 修改百度推送
     */
    @PreAuthorize("@ss.hasPermi('blog:sitePush:edit')")
    @Log(title = "百度推送", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SitePush sitePush)
    {
        return toAjax(sitePushService.updateSitePush(sitePush));
    }

    /**
     * 删除百度推送
     */
    @PreAuthorize("@ss.hasPermi('blog:sitePush:remove')")
    @Log(title = "百度推送", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sitePushService.deleteSitePushByIds(ids));
    }
}
